// vite.config.js
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";

export default defineConfig({
  plugins: [uni()],
  server: {
    host: '0.0.0.0',
    port: 8080,
    strictPort: true, // 禁止自动切换端口
    proxy: {
      '^/api': {  // 更严格的正则匹配
        target: 'http://107.149.246.147:8888',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
        bypass(req) {
          console.log('代理触发:', req.url); // 验证代理是否生效
        }
      }
    }
  }
})